<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>新增定时任务调度</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <script type="text/javascript" src="../../common/js/public.js"></script>
    <script type="text/javascript" src="../../common/js/publicUtils.js"></script>
    <style>
        .layui-input-inline,.buttondiv .layui-input-inline {
            float: left;
            width: 400px !important;
            margin-right: 10px;
        }
        .layui-form-label {
            width: 110px !important;
        }
        .error{
            color: red;
            line-height: 20px;
        }
        .worntype{
            font-size: 10px;
            margin-top: 2px;
            color: grey;
            margin-left: 4px;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form"  id="form" >
            <div class="layui-form-item">
                <label class="layui-form-label" for="jobName"><span style="color: red;">*</span>任务名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="jobName" id="jobName"  placeholder="请输入任务名称" class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="jobGroup"><span style="color: red;">*</span>任务组名</label>
                <div class="layui-input-inline">
                    <select id="jobGroup" name="jobGroup">
                        <option value="DEFAULT">默认</option>
                        <option value="SYSTEM">系统</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="invokeTarget"><span style="color: red;">*</span>调用目标字符串</label>
                <div class="layui-input-inline">
                    <input type="text" name="invokeTarget" id="invokeTarget"  placeholder="请输入调用目标字符串" class="layui-input" >
                    <p class="worntype"><i class="layui-icon layui-icon-about"></i>Bean调用示例：ryTask.ryParams('ry')</p>
                    <p class="worntype"><i class="layui-icon layui-icon-about"></i>Class类调用示例：com.ruoyi.quartz.task.RyTask.ryParams('ry')</p>
                    <p class="worntype"><i class="layui-icon layui-icon-about"></i>参数说明：支持字符串，布尔类型，长整型，浮点型，整型</p>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="cronExpression"><span style="color: red;">*</span>cron执行表达式</label>
                <div class="layui-input-inline">
                    <input type="text" name="cronExpression" id="cronExpression"  placeholder="请输入cron执行表达式" class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="misfirePolicy"><span style="color: red;">*</span>执行策略</label>
                <div class="layui-input-inline">
                    <select id="misfirePolicy" name="misfirePolicy">
                        <option value="1">立即触发执行</option>
                        <option value="2">触发一次执行</option>
                        <option value="3">放弃触发执行</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red;">*</span>状态</label>
                <div class="layui-input-inline">
                    <input type="radio" name="status" value="0" title="正常" checked>
                    <input type="radio" name="status" value="1" title="停止">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red;">*</span>是否并发执行</label>
                <div class="layui-input-inline">
                    <input type="radio" name="concurrent" value="0" title="允许" checked>
                    <input type="radio" name="concurrent" value="1" title="暂停">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="comment">备注信息</label>
                <div class="layui-input-inline">
                    <textarea name="comment" id="comment" placeholder="请输入备注信息" class="layui-textarea" ></textarea>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    $(function(){
        layui.use('form',function(){
            var form = layui.form;
        })
    })
    /**
     * @author 
     * @date Fri Jan 17 08:26:21 CST 2020
     * 提交
     */
    function submit(){
        var data = $("#form").serializeJson();
        var url = 'system/quartz/add';
        var obj = $(validform().form());
        if(!obj[0]){
            return false;
        }
        var result;
        publicAjax (null,url,data,false,null,function (r) {
            if(r.code==2000){
                laysuccess("添加成功",null);
                result = r;
            }else{
                layerror("添加失败",null);
                result = r;
            }
        });
        return result;
    }


    //编写表单验证函数validform，在验证按钮注册按钮点击事件内调用验证函数对象
    function validform(){
        return $("#form").validate({
            ignore: ":hidden:not(select)",//解决无法校验select
            rules : {
                jobName : {
                    required:true,
                    normalizer: function( value ) {
                      return $.trim( value );
                    }
                },
                jobGroup : {
                    required:true,
                    normalizer: function( value ) {
                      return $.trim( value );
                    }
                },
                invokeTarget : {
                    required:true,
                    normalizer: function( value ) {
                      return $.trim( value );
                    }
                },
                cronExpression : {
                    required:true,
                    normalizer: function( value ) {
                      return $.trim( value );
                    }
                },
                misfirePolicy : {
                    required:true,
                    normalizer: function( value ) {
                      return $.trim( value );
                    }
                },
                status : {
                    required:true,
                    normalizer: function( value ) {
                      return $.trim( value );
                    }
                },
                comment : {
                    maxlength: 100,
                    normalizer: function( value ) {
                      return $.trim( value );
                    }
                },
                concurrent : {
                    required:true,
                    normalizer: function( value ) {
                      return $.trim( value );
                    }
                },
            },
            messages : {
                jobName : {
                    required:"任务名称不能为空"
                },
                jobGroup : {
                    required:"任务组名不能为空"
                },
                invokeTarget : {
                    required:"调用目标字符串不能为空"
                },
                cronExpression : {
                    required:"cron执行表达式不能为空"
                },
                misfirePolicy : {
                    required:"计划执行错误策略不能为空"
                },
                status : {
                    required:"状态不能为空"
                },
                comment : {
                    required:"备注信息长度不能超过100"
                },
                concurrent : {
                    required:"是否并发执行不能为空"
                },
            }
        });
    }


</script>
</body>

</html>